﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gsn.Base.Notification.Calendar
{

    /// <summary>
    /// Delegate type for referring to functions handling calendar notifications.
    /// </summary>
    /// <param name="source">The IEngine that raises the call</param>
    /// <param name="calendarNotification">Notification's data</param>
    public delegate void CalendarNotificationHandler(ICalendarEngine source, CalendarNotification calendarNotification);

    public enum CalendarNotificationPriority { High, Medium, Low }

    public class CalendarNotification : ICollection<CalendarNotificationElement>
    {
        private CalendarNotificationPriority calendarNotificationPriority_;
        private String title_;
        private DateTime createdTime_;
        private ICollection<CalendarNotificationElement> collection_;

        public CalendarNotificationPriority Priority
        {
            get
            {
                return calendarNotificationPriority_;
            }
        }

        public String Title
        {
            get
            {
                return title_;
            }
        }

        public DateTime Created
        {
            get
            {
                return createdTime_;
            }
        }

        public CalendarNotification(String title, CalendarNotificationPriority calendarNotificationPriority)
        {
            title_ = title;
            createdTime_ = DateTime.Now;
            calendarNotificationPriority_ = calendarNotificationPriority;
            
            collection_ = new List<CalendarNotificationElement>();
        }

        #region ICollection<ServiceEventElement> Members

        public void Add(CalendarNotificationElement item)
        {
            collection_.Add(item);
        }

        public void Clear()
        {
            collection_.Clear();
        }

        public bool Contains(CalendarNotificationElement item)
        {
            return collection_.Contains(item);
        }

        public void CopyTo(CalendarNotificationElement[] array, int arrayIndex)
        {
            collection_.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return collection_.Count; }
        }

        public bool IsReadOnly
        {
            get { return collection_.IsReadOnly; }
        }

        public bool Remove(CalendarNotificationElement item)
        {
            return collection_.Remove(item);
        }

        #endregion

        #region IEnumerable<ServiceEventElement> Members

        public IEnumerator<CalendarNotificationElement> GetEnumerator()
        {
            return collection_.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return collection_.GetEnumerator();
        }

        #endregion
    }

    public class CalendarNotificationElement
    {
        private String title_;
        private String summary_;
        private DateTime startDateTime_;
        private DateTime endDateTime_;

        public CalendarNotificationElement(String title, String summary, DateTime startDateTime, DateTime endDateTime)
        {
            title_ = title;
            summary_ = summary;
            startDateTime_ = startDateTime;
            endDateTime_ = endDateTime;
        }

        public String Title
        {
            get
            {
                return title_;
            }
        }

        public String Description
        {
            get
            {
                return summary_;
            }
        }

        public DateTime StartDateTime
        {
            get
            {
                return startDateTime_;
            }
        }

        public DateTime EndDateTime
        {
            get
            {
                return endDateTime_;
            }
        }
    }
}
